<?php 

namespace app\api\validate;

use app\api\validate\BaseValidate;

class IDMustBePostiveInt extends BaseValidate
{
	protected $rule = [
		'id' => 'require|isPositiveInteger'
	];

	// 自定义验证规则
	protected function isPositiveInteger($value, $rule = '', $data = '', $field = '')
	{
		if ($value && is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) {
			return true;
		} 
		else {
			return $field.'必须为整形';
		}
	}
}